<template name="ClienteleList">
	<view>
		<clientele-item v-for="(item, index) in list" :item="item" :key="index" @click="itemClick(item)"></clientele-item>
		<u-loadmore v-if="!emptyShow" :status="status" />
		<u-empty class="noContent" v-if="emptyShow" text="暂时没有记录哦～"  mode="list"></u-empty>
	</view>
</template>

<script>
	import ClienteleItem from '@/pages_operate/clientele/components/clientele-item.vue'
	import { getContinueClientelePage, getClientele } from '@/api/clientele.js'
	import pageMixin from '@/mixins/page.js'
	export default {
		name: 'ClienteleList',
		mixins: [pageMixin],
		components: {
			ClienteleItem
		},
		props: {
			type: {
				type: Number,
				default () {
					return 0;
				}
			},
		},
		data() {
			return {
			}
		},
		created() {
			this.getList(this.page);
		},
		methods: {
			getList(page) {
				if (this.type === 0) {
					this.getClienteleType(this.page)
				} else if (this.type === 1) {
					this.getContinueClientele(this.page)
				} else if (this.type === 2) {
					this.getClienteleBycfm(this.page)
				} else if (this.type === 3) {
					this.getClientele(this.page)
				}
			},
			
			//A类客户
			getClienteleType(page) {
				const areaId = this.$store.state.user.tchInfo.area.id
				const clienteleType = "'A'";
				let data = {
					areaId: areaId,
					clienteleType: clienteleType,
					pageNum: page + 1,
					pageSize: 20,
				}
				getContinueClientelePage(data).then(res => {
					console.log(res);
					this.setData(res);
				})
			},
			//待续约客户
			getContinueClientele(page) {
				const areaId = this.$store.state.user.tchInfo.area.id
				const continueKey = "'ck'";
				let data = {
					areaId: areaId,
					continueKey: continueKey,
					pageNum: page + 1,
					pageSize: 20,
				}
				getContinueClientelePage(data).then(res => {
					console.log(res);
					this.setData(res);
				})
			},
			//待补款
			getClienteleBycfm(page) {
				const areaId = this.$store.state.user.tchInfo.area.id
				const continueFillMoneyKey = "'cfm'";
				let data = {
					areaId: areaId,
					continueFillMoneyKey: continueFillMoneyKey,
					pageNum: page + 1,
					pageSize: 20,
				}
				getClientele(data).then(res => {
					console.log(res);
					this.setData(res);
				})
			},
			
			//全部
			getClientele(page) {
				const areaId = this.$store.state.user.tchInfo.area.id
				const continueFillMoneyKey = '';
				let data = {
					areaId: areaId,
					continueFillMoneyKey: continueFillMoneyKey,
					pageNum: page + 1,
					pageSize: 20,
				}
				getClientele(data).then(res => {
					console.log(res);
					this.setData(res);
				})
			},
			
			itemClick(item) {
				this.$u.route({
					url: 'pages_operate/clientele/lead-detail-page',
					params: {
						leadsId: item.id,
						type: 0
					}
				})
			},
		}
	}
</script>

<style>
</style>
